<template>
  <div class="box">
    <!-- 标题 -->
    <div class="title">
      <div class="title_fan">
        <div class="el-icon-arrow-left" @click="$router.go(-1)"></div>
      </div>
      <!-- 文字 钱包余额 -->
      <div class="title_cen">
        <div class="title_cen_title">MiniMart</div>
        <div class="title_cen_size">钱包余额</div>
        <div class="title_cen_flex">
          <img src="../../../../assets/static/walletDetail/12.png" alt="">
          <div>{{ info.balance }}</div>
        </div>
        <div class="title_cen_color">{{ info.machine_code }}</div>
        <div @click="add" class="title_cen_backimg">OPEN</div>
      </div>
    </div>
    <!-- 商品列表 -->
    <div class="goods_list">
      <div class="card_title">
        <img src="../../../../assets/static/recharge/q4.png" alt=""/>
        <div>商品列表</div>
      </div>
      <!--  -->
      <div class="goods_list_info">
        <div class="goods_list_info_title">
          <div>商品类型</div>
          <div>商品名称</div>
          <div>商品图片</div>
          <div>商品价格（原价/现价）</div>
        </div>
        <div v-for="item in dataList" :key="item.ROW_NUMBER">
          <div></div>
          <div class="row-wrapper">
            <span>{{ item.name }}</span>
          </div>
          <div>
            <img class="goodsImg" :src="item.pic" alt="商品图片"/>
          </div>
          <div class="row-wrapper price">
            <span>{{ item.oldprice }}/</span>
            <span>{{ item.price }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {index, goodslist} from '@/api/merbership/goods'
import {add} from '@/api/merbership/openmachine'
import '@/styles/flax.css'

export default {
  data() {
    return {
      dataList: [],
      info: {},
      machine_code: 'B1001',
      utmInfo: {
        utm_source: 'qrcode',
        utm_medium: 'kiosk',
        kioskid: 'B1001'
      }
    }
  },
  methods: {
    /**
     * 扫码点击open按钮
     */
    add() {
      const pd = {
        machine_code: this.machine_code
      }
      add(this.$qs.stringify(pd))
        .then(res => {
          this.$message.success(res.data.msg)
        })
    },
    /**
     * 商品列表
     */
    index() {
      const pd = {}
      index(this.$qs.stringify(pd))
        .then(res => {
          this.info = res.data.data
        })
    },
    /**
     * 机器内的商品列表
     */
    goodslist() {
      goodslist(this.$qs.stringify(this.utmInfo))
        .then(res => {
          this.info = res.data.data
          console.log(this.info)
          this.dataList = res.data.data.goodsdata
        })
    }
  },
  mounted() {
    // this.index()
    this.goodslist()
  }
}
</script>

<style lang="scss" scoped>
.price {
  justify-content: center;
}

.goodsImg {
  width: 40px;
  height: 80px;
}

.box {

  /* 标题 */
  .title {
    background-image: linear-gradient(to bottom, #7ac91b 65%, #f5f5f5 0);
    font-weight: bold;

    .title_fan {
      color: #fff;
      font-size: 18px;
      padding: 15px;
    }

    .title_cen {
      font-weight: normal;
      margin: 0 15px;
      padding: 20px 15px 6px 15px;
      background-color: #fff;
      border-radius: 15px;
      box-shadow: 0 0 10px #ccc;
      text-align: center;
      color: #333333;

      .title_cen_title {
        font-size: 25px;
        color: #67C022;
        //font-style: AlibabaPuHuiTiB;
        font-weight: bold;
        text-shadow: #67C022 0 2px 3px;
      }

      .title_cen_size {
        font-size: 11px;
        margin: 30px 0 20px 0;
      }

      .title_cen_flex {
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 21.5px;
        font-weight: bold;

        img {
          width: 21px;
          height: 21px;
          margin-right: 6px;
        }
      }

      .title_cen_color {
        color: #FFB400;
        font-size: 11px;
        margin-top: 28px;
      }

      .title_cen_backimg {
        width: 180px;
        margin: auto;
        padding: 14px 0 21px 0;
        text-align: center;
        color: #FFFFFF;
        font-weight: bold;
        font-size: 12px;
        background-image: url(../../../../assets/static/scanOpen/7.png);
        background-repeat: no-repeat;
        background-size: 100% 100%;
      }
    }
  }

  /* 商品列表 */
  .goods_list {
    margin: 15px;

    .card_title {
      display: flex;
      font-size: 15px;
      font-weight: bold;

      > div {
        margin-left: 13px;
      }
    }

    .goods_list_info {
      margin: 15px 0;
      background-color: #fff;
      border-radius: 10px;
      font-size: 11px;
      color: #666666;
      box-shadow: 0 0 10px #ccc;

      > div {
        display: flex;
        border-bottom: #D8D8D8 solid 1px;

        > div {
          width: 25%;
          padding: 14px 0;
          text-align: center;
          border-right: #D8D8D8 solid 1px;
        }

        > div:last-child {
          border: none;
        }
      }

      > div:last-child {
        border: none;
      }

      .goods_list_info_title {
        font-size: 12px;
        font-weight: bold;
        color: #333333;
      }
    }
  }
}
</style>
